/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jcgame;

import Action.Actions;
import IO.Utils;
import IO.models.ItemsConfig;
import IO.models.MapsConfig;
import IO.models.PlayerConfig;
import java.io.Console;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import jcurses.system.Toolkit;
import net.slashie.libjcsi.ConsoleSystemInterface;
import net.slashie.libjcsi.jcurses.JCursesConsoleInterface;
import net.slashie.libjcsi.wswing.WSwingConsoleInterface;

/**
 *
 * @author insane
 */
public class Main {

    //public static ConsoleSystemInterface csi = new WSwingConsoleInterface("game", true);
    public static ConsoleSystemInterface csi = new JCursesConsoleInterface();

    public static void main(String[] p) throws FileNotFoundException, ClassNotFoundException, IOException, InterruptedException {
        Main mn = new Main();
        //mn.init();
        
        Utils.timeStart();
        Actions.main(p);

    }

    private void init() {
        ShutdownHook shutdownHook = new ShutdownHook();
        Runtime.getRuntime().addShutdownHook(shutdownHook);
    }

    class ShutdownHook extends Thread {

        @Override
        public void run() {
            
            try {
                //ItemsConfig.getInstance().save();
                //MapsConfig.getInstance().save();
                PlayerConfig.getInstance().save();
            } catch (ClassNotFoundException ex) {
                Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
            } catch (FileNotFoundException ex) {
                Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
            }
            Toolkit.endPainting();
            Toolkit.shutdown();
            Toolkit.unsetClipRectangle();
       }
    }
}
